package com.tuuzed.hydrogen.simple.quickstart;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.tuuzed.adapter.ItemProvider;
import com.tuuzed.hydrogen.simple.R;
import com.tuuzed.hydrogen.simple.model.UserModel;


public class UserItemProvider extends ItemProvider<UserModel> {


    @Override
    public void onBindViewHolder(@NonNull com.tuuzed.adapter.ViewHolder holder, @NonNull final UserModel userModel, int position) {


        holder.$(R.id.text, TextView.class).setText(userModel.toString());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(), UserActivity.class);
                intent.putExtra(UserActivity.EXTRA_USER, userModel.getId());
                getContext().startActivity(intent);
            }
        });
    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item;
    }
}
